<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<input type="hidden" value="<%=basePath%>" id="basePath">

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css"
          href="<%=basePath%>/assets/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet"
          href="<%=basePath%>/assets/bootstrap/css/bootstrap.css"/>
    <script type="text/javascript"
            src="<%=basePath%>/assets/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript"
            src="<%=basePath%>/assets/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript"
            src="<%=basePath%>/assets/lib/layer/2.4/layer.js"></script>
    <script src="<%=basePath%>/assets/js/exam/exam-update.js"
            type="text/javascript" charset="utf-8"></script>
    <title>试题管理</title>
    <style type="text/css">
        .objectSinglePloy {
            appearance: none;
            -moz-appearance: none;
            -webkit-appearance: none;
            height: 34px;
            width: 33%;
            padding: 6px 12px;
            font-size: 14px;
            line-height: 1.42857143;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #ccc;
            border-radius: 4px;
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
            -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
            -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
            transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        }

        .answerPoint {
            padding-left: 10px;
        }

        .waring {
            position: fixed;
            top: 23%;
            right: 5%;
            min-height: 80px;
            width: 15%;
            padding: 6px 8px;
            box-shadow: 10px 20px 35px;
        }

        .notice {
            padding: 3px 0px 8px 10px;
        }
    </style>
</head>
<body>
<br>
<div class="alert alert-warning alert-dismissible waring" role="alert">
    <h4 class="text-center">注意</h4>
    <ul class="notice">
        <li>试题分类不可修改；</li>
        <li>修改后的试题题干不可与已存在的试题题干相同，系统将会对此进行验证；</li>
        <li>需要增加答案项时，请点击添加按钮；</li>
        <li>需要减少答案项时，请点击“叉号”进行删除；</li>
    </ul>
</div>
<div class="container-fluid">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="tabbable" id="tabs-576364">
                <ul class="nav nav-tabs">
                    <li
                            <c:if test="${examDetails.examination.category == 1 or examDetails.examination.category == 2 or examDetails.examination.category == 3 or examDetails.examination.category == 4}">class="active"</c:if> ><a>第一站问答</a>
                    </li>
                    <li
                            <c:if test="${examDetails.examination.category == 7 or examDetails.examination.category == 8 or examDetails.examination.category == 9 or examDetails.examination.category == 10 or examDetails.examination.category == 11 or examDetails.examination.category == 12}">class="active"</c:if> >
                        <a>第二站常规化</a></li>
                    <li
                            <c:if test="${examDetails.examination.category == 15}">class="active"</c:if> ><a>第二站客观化</a></li>
                </ul>
                <br/>
                <div class="tab-content">
                    <!--第一站问答-->
                    <div>
                        <form class="form-horizontal" method="post" id="examForm">
                            <!-- 发送题目id -->
                            <input type="hidden" name="id" value="${examDetails.examination.id}" id="commonId">
                            <!-- 题目分类 -->
                            <input type="hidden" name="category" value="${examDetails.examination.category}" id="categoryCommon"/>
                            <div class="col-md-9">
                                <c:if test="${examDetails.examination.category == 4}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-4">
                                            <select class="form-control" disabled="disabled">
                                                <option>伤科按摩学</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>
                                <c:if test="${examDetails.examination.category == 2}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-4">
                                            <select name="category" class="form-control" disabled="disabled">
                                                <option>妇科按摩学</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>
                                <c:if test="${examDetails.examination.category == 1}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-4">
                                            <select name="category" class="form-control" disabled="disabled">
                                                <option>内科按摩学</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>
                                <c:if test="${examDetails.examination.category == 3}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-4">
                                            <select name="category" class="form-control" disabled="disabled">
                                                <option>儿科推拿学</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>
                                <c:if test="${examDetails.examination.category == 15}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-2">
                                            <select class="form-control" disabled="disabled">
                                                <option>客观化</option>
                                            </select>
                                        </div>
                                        <div class="col-md-2">
                                            <select name="category" class="form-control" disabled="disabled">
                                                <option>单项手法</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>

                                <c:if test="${examDetails.examination.category == 7}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-2">
                                            <select class="form-control" disabled="disabled">
                                                <option>单项手法</option>
                                            </select>
                                        </div>
                                        <div class="col-md-2">
                                            <select name="category" class="form-control" disabled="disabled">
                                                <option>成人手法</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>
                                <c:if test="${examDetails.examination.category == 8}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-2">
                                            <select class="form-control" disabled="disabled">
                                                <option>单项手法</option>
                                            </select>
                                        </div>
                                        <div class="col-md-2">
                                            <select name="category" class="form-control" disabled="disabled">
                                                <option>儿科手法</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>
                                <c:if test="${examDetails.examination.category == 9}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-2">
                                            <select class="form-control" disabled="disabled">
                                                <option>整套手法</option>
                                            </select>
                                        </div>
                                        <div class="col-md-2">
                                            <select name="category" class="form-control" disabled="disabled">
                                                <option>伤科</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>
                                <c:if test="${examDetails.examination.category == 10}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-2">
                                            <select class="form-control" disabled="disabled">
                                                <option>整套手法</option>
                                            </select>
                                        </div>
                                        <div class="col-md-2">
                                            <select name="category" class="form-control" disabled="disabled">
                                                <option>妇科</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>
                                <c:if test="${examDetails.examination.category == 11}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-2">
                                            <select class="form-control" disabled="disabled">
                                                <option>整套手法</option>
                                            </select>
                                        </div>
                                        <div class="col-md-2">
                                            <select name="category" class="form-control" disabled="disabled">
                                                <option>儿科</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>
                                <c:if test="${examDetails.examination.category == 12}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">分类</label>
                                        <div class="col-md-2">
                                            <select class="form-control" disabled="disabled">
                                                <option>整套手法</option>
                                            </select>
                                        </div>
                                        <div class="col-md-2">
                                            <select name="category" class="form-control" disabled="disabled">
                                                <option>内科</option>
                                            </select>
                                        </div>
                                    </div>
                                </c:if>

                                <!--题干-->
                                <div class="form-group">
                                    <label class="col-md-2 control-label">题干</label>
                                    <div class="col-md-9">
                                        <input type="text" name="stem" id="commonStem" class="form-control" value="${examDetails.examination.stem}"
                                               onblur="validateStemForUpdateExam('${examDetails.examination.id}',${examDetails.examination.category},this.value)" required/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-2 control-label">知识点</label>
                                    <div class="col-md-4">
                                        <input type="text" class="form-control" name="knowledgePoint" value="${examDetails.examination.knowledgePoint}"/>
                                    </div>
                                    <label class="col-md-1 control-label answerPoint">总分</label>
                                    <div class="col-md-4">
                                        <input type="number" name="totalScore" class="form-control"
                                               value="${examDetails.examination.totalScore}"/>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-2 control-label">大纲</label>
                                    <div class="col-md-4">
                                        <input type="text" class="form-control" name="outlineCode"
                                               value="${examDetails.examination.outlineCode}"/>
                                    </div>

                                    <label class="col-md-1 control-label answerPoint">认知</label>
                                    <div class="col-md-4">
                                        <select id="commonCognitiveLevel" name="cognitiveLevel" class="form-control">
                                            <option value="记忆"  <c:if test="${examDetails.examination.cognitiveLevel == \"记忆\"}"> selected</c:if> >记忆</option>
                                            <option value="理解" <c:if test="${examDetails.examination.cognitiveLevel == \"理解\"}"> selected</c:if>>理解</option>
                                            <option value="应用" <c:if test="${examDetails.examination.cognitiveLevel == \"应用\"}"> selected</c:if>>应用</option>
                                        </select>
                                    </div>
                                </div>


                                <!--答案-->
                                <c:forEach var="item" items="${examDetails.answerCommonList}" begin="0" end="0" step="1">
                                    <input type="hidden" value="${examDetails.answerCommonList.size()}" id="countAnswerCommon">
                                    <div class="form-group " id="anserTerm">
                                        <label class="col-sm-2 control-label">答案</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" name="commonAnswerList[0].answer" value="${item.answer}"/>
                                        </div>
                                        <label class="col-sm-1 control-label answerPoint">分值</label>
                                        <div class="col-sm-2">
                                            <input type="number" class="form-control" value="${item.score}" name="commonAnswerList[0].score"  <c:if test="${examDetails.examination.category == 15}"> disabled</c:if>/>
                                        </div>
                                        <div class="col-sm-1">
                                            <button class="btn  btn-primary" type="button"
                                                    id="addCommonAnswerButton"><i class="glyphicon glyphicon-plus"></i>&nbsp;添加
                                            </button>
                                        </div>
                                    </div>
                                </c:forEach>
                                <c:forEach var="item" items="${examDetails.answerCommonList}" begin="1" end="5" step="1" varStatus="status">
                                    <div class="form-group ">
                                        <div class="col-sm-2">
                                            <i class="glyphicon glyphicon-remove" style="margin-left: 80%;margin-top:12%;cursor: pointer;" onclick="deleteNewAddB(this)"></i>
                                        </div>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" name="commonAnswerList[${status.index}].answer" value="${item.answer}"/>
                                        </div>
                                        <label class="col-sm-1 control-label answerPoint">分值</label>
                                        <div class="col-sm-2">
                                            <input type="number" class="form-control" value="${item.score}" name="commonAnswerList[${status.index}].score"   <c:if test="${examDetails.examination.category == 15}"> disabled</c:if>/>
                                        </div>
                                    </div>
                                </c:forEach>
                            </div>
                            <div class="form-group">
                                <div class="col-md-6" style="text-align: center;">
                                    <input class="btn btn-default" type="button"
                                           id="updateExam" value="修改"
                                           style="background-color: #008200; color: white;"/>
                                    <button class="btn btn-default" type="reset">重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    $("#updateExam").click(function () {
        var id = $("#commonId").val();
        var category = $('#categoryCommon').val();
        var stem = $("#commonStem").val();
        var validateStem = validateStemForUpdateExam(id, category, stem);
        if (validateStem == false) {
            return false;
        }

        $.post('<%=basePath%>/examination/examinationUpdate', $("#examForm").serialize(), function (data) {
            if (data.code==0) {
                layer.msg(data.msg, {
                    icon: 1,
                    time: 3000
                });
            }
        },"json");
    });
</script>
</html>